<%@ page import="cn.school.service.SubjectService" %>
<%@ page import="cn.school.entity.Subject" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.school.service.GradeService" %>
<%@ page import="cn.school.entity.Grade" %>
<%@ page import="java.util.Map" %><%--
  Created by IntelliJ IDEA.
  User: ghost
  Date: 2019/12/9
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
<%@include file="checkLogin.jsp"%>
<table border="1" cellpadding="10" cellspacing="0">
    <tr><td>课程名称</td><td>课时</td><td>班级</td></tr>
<%
    int pageNo = (int) request.getAttribute("pageNosb");
    List<Subject> list = (List<Subject>) request.getAttribute("list");
    Map<String,String> map = (Map<String, String>) request.getAttribute("map");
    for(Subject s : list){%>
    <tr><td><%=s.getSubjectname()%></td><td><%=s.getClassHour()%></td><td><%=map.get(Long.toString(s.getGradeid()))%></td></tr>
<%
    }
%>
</table>
<%
    int total = (int) request.getAttribute("total");
    int max = total + 1;
    if(total > 1){
        if(pageNo != 1){
            out.print("<a href='subjectinfo?pageNosb=1'>首页</a>");
            out.print("<a href='subjectinfo?pageNosb="+(pageNo-1)+"'>上一页</a>");
        }%>
            <input type="text" name="go" style="width:35px;" value="<%=pageNo%>">/<%=max%>页
        <%
        if(pageNo != total+1){
            out.print("<a href='subjectinfo?pageNosb="+(pageNo+1)+"'>下一页</a>");
            out.print("<a href='subjectinfo?pageNosb="+max+"'>尾页</a>");
        }
    }
%>
</body>
<script>
    $(function(){
        $("input[name=go]").keydown(function(event){
            if(event.keyCode == 13){
                if(this.value==""||isNaN(this.value)){
                    return false;
                }
                window.location = "subjectinfo?pageNosb="+$(this).val();
            }
        }).blur(function(){
            if(this.value==""||isNaN(this.value)){
                return false;
            }
            window.location = "subjectinfo?pageNosb="+$(this).val();
        });
    });
</script>
</html>
